/**
 * 发货
 */
var stockSendWin = function(orderId) {
	var stockSendForm = new Ext.form.FormPanel({
		id : 'stockSendForm',
		frame : true,
		buttonAlign : 'center',
		labelAlign : 'right',
		monitorValid : true,
		bodyBorder : false,
		border : false,
		buttons : [{
					text : "保存",
					width : 80,
					id : 'logisticNoSave',
					handler : function() {
						var b = Ext.getCmp("stockSendForm");
						if (b.getForm().isValid()) {
							b.getForm().submit({
										url : __ctxPath
												+ "/orderManager/stockSend",
										method : "post",
										waitTitle : "请稍候",
										waitMsg : "正在提交表单，请稍候......",
										success : function(c, d) {
											Ext.MessageBox.show({
														title : "操作信息",
														msg : "保存成功!",
														buttons : Ext.MessageBox.OK,
														icon : Ext.MessageBox.INFO
													});
											stockSendWindow.close();
											queryOrders();
										},
										failure : function(c, d) {
											Ext.MessageBox.show({
														title : "操作信息",
														msg : '保存失败!',
														buttons : Ext.MessageBox.OK,
														icon : Ext.MessageBox.ERROR
													});
										}
									});
						}
					}
				}, {
					text : "取消",
					width : 80,
					handler : function() {
						stockSendWindow.close();
					}
				}],
		reader : new Ext.data.JsonReader({
					success : 'success',
					root : 'data'
				}, [{
							name : "id"
						}, {
							name : "orderCode"
						}, {
							name : "userId"
						}, {
							name : "userPaymentId"
						}, {
							name : "orderStatus"
						}, {
							name : "payStatus"
						}, {
							name : "payType"
						}, {
							name : "payDate"
						}, {
							name : "limitPayDate"
						}, {
							name : "totalAmount"
						}, {
							name : "goodsNumber"
						}, {
							name : "payAmount"
						}, {
							name : "deliveryDate"
						}, {
							name : "deliveryTimes"
						}, {
							name : "deliveryFee"
						}, {
							name : "isUserCoupon"
						}, {
							name : "couponId"
						}, {
							name : "couponFee"
						}, {
							name : "consignee"
						}, {
							name : "consignPhone"
						}, {
							name : "consignAddress"
						}, {
							name : "birthdayTitle"
						}, {
							name : "birthdayCard"
						}, {
							name : "remark"
						}, {
							name : "payGoodsName"
						}, {
							name : "cancelDate"
						}, {
							name : "cancelReason"
						}, {
							name : "createdDate"
						}, {
							name : "createdName"
						}, {
							name : "updatedDate"
						}, {
							name : "updatedName"
						}, {
							name : "cancelName"
						}, {
							name : "receivedDate"
						}, {
							name : "logisticNo"
						}]),
		items : [{
					columnWidth : .25,
					layout : 'form',
					items : [{
								xtype : "hidden",
								id : 'orderForm_orgId',
								name : "id",
								anchor : '100%'
							}, {
								xtype : "textfield",
								id : 'stockSendForm_logisticNo',
								fieldLabel : "物流单号",
								anchor : '100%',
								name : "logisticNo"
							}]
				}]
	});

	var stockSendWindow = new Ext.Window({
				id : 'stockSendWindow',
				closeAction : 'close',
				title : '填写物流单号',
				modal : true,
				width : 350,
				height : 340,
				plain : true,
				layout : 'fit',
				buttonAlign : 'center',
				autoDestroy : true,
				items : [stockSendForm],
				listeners : {
					'show' : function() {
						setLogisticNoById(orderId);
					},
					'beforeshow' : function() {
						stockSendWindow.center();
					}
				}
			});
	return stockSendWindow;
}

/**
 * 根据orderId查询改orderModel对象
 * 
 * @param {}
 *            orderId
 */
function setLogisticNoById(orderId) {
	if (orderId != null && orderId != "undefined") {
		Ext.getCmp("stockSendForm").getForm().load({
					deferredRender : false, // 子项仅在被激活时才渲染
					url : __ctxPath + "/orderManager/findOrderById",
					params : {
						orderId : orderId
					},
					waitTitle : "请稍候",
					waitMsg : "正在载入数据...",
					root : "data",
					success : function(response, options) {
						var data = options.result.data;
					},
					failure : function(f, g) {
						Ext.MessageBox.show({
									title : "操作信息",
									msg : "数据加载失败!",
									buttons : Ext.MessageBox.OK,
									icon : Ext.MessageBox.ERROR
								});
					}
				});
	}
}